# 迭代器方式斐波拉契
class Feibolaqi(object):

    def __init__(self, num):
        self.num = num
        self.count = 0
        self.x = 0
        self.y = 1

    def __iter__(self):
        return self

    def __next__(self):
        if self.count < self.num:
            self.x, self.y = self.y, self.x + self.y
            self.count += 1
            return self.x
        else:
            raise StopIteration


if __name__ == "__main__":

    for num in Feibolaqi(10):
        print(num)
